<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <p>hello world</p>
        <div id="shadow"></div>
    </div>
    <script>
        let shadomDOM = document.getElementById('shadow').attachShadow({
            mode: 'closed'
        });

        let pElm = document.createElement('p');
        pElm.innerHTML = 'hello zf';
        let styleElm = document.createElement('style');
        styleElm.textContent = `
            p{color:red}
        `

        shadomDOM.appendChild(styleElm);
        shadomDOM.appendChild(pElm);

        // document.body.appendChild(pElm);
    </script>
</body>
</html>